import { Provider } from "react-redux";
import store from "./index";

/**想用redux的话，需要在根页面用这个高阶组件进行包裹，才能使用  （需要是客户端渲染） */
export const withRedux = (WrappedComponent: React.ComponentType<any>) => {
  const WithRedux = (props: any) => (
    <Provider store={store}>
      <WrappedComponent {...props} />
    </Provider>
  );
  return WithRedux;
};

//这个好像是做数据持久化的，暂时不用
// import { PersistGate } from 'redux-persist/integration/react';
// import makeStore from './index';
// const { store, persistor } = makeStore();
// export const withReduxPersist = (WrappedComponent: React.ComponentType) => {
//   const WithReduxPersist = (props: any) => (
//     <PersistGate persistor={persistor}>
//       <WrappedComponent {...props} />
//     </PersistGate>
//   );

//   return WithReduxPersist;
// };
